// pages/fabu/index.js
var util=require("../../utils/util.js")
var myRequest=require("../../utils/require.js")
import WxValidate from '../../utils//WxValidate'
const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:'',
    owndesc:'',
    successModal:null,
    is_placehold:true,
    imgList: [],
    bottomModal:null,
    shuzi:[1,2,3,4,5,6,7,8,9,'.',0,'面议'],
    rent:'',
 
    address:'',
    rent_price:'0.00',
    sure_rent:'',
    jibenModal:null,//基本信息弹窗
    moreModal:null,//更多信息弹窗
    owner:'',//业主
    owner_tel:'',//联系电话
    city:[],
    city_index:[0,0],
    onlyArray: [
      [],
      []
    ],
    high:'',//层高
    floor:'',//所在楼层
    area:'',//面积
    industry:[], //类型
    hangye:[],//适合行业
    chengzhong:[],//承重类型
    zhengjian:[],//证件
    changfang_type:[],//厂房类型
    hangye_index:[],
    industry_index:[],
    park:[],
    tags:[],
    tags_index:[],
    tags_id:[],
    industry_id:'',
    edit:'',
    hangye_id:'',
    chengzhong_id:'',
    zhengjian_id:'',
    changfang_type_id:'',
    park_id:'',
    city_id:'',
    qu_id:'',
    token:'',
    img:[],
    isEdit:false,
    isPickerRender: false,
    isPickerShow: false,
    startTime: "2019-01-01",
    endTime: "2019-12-01",
    pickerConfig: {
      endDate: true,
      column: "",
      dateLimit: true,
      initStartTime: "2019-01-01",
      initEndTime: "2019-12-01",
      limitStartTime: "2015-05-06",
      limitEndTime: "2055-05-06"
    },
    fabu:null,
    code: ''
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      let id=options.id;
    if (id != undefined) {
      this.setData({
        id:id
      })
    }
    if(options.edit!=undefined){
      this.setData({
        edit:options.edit
      })
    }
    
      console.log('option',options)
      let code=options.code
    app.GetUser().then(res => {
      console.log('得到user', res)
      this.setData({
        userInfo: res
      })
      if(code!=undefined){
        this.setData({
          code:code
        })
      }
      if (id != undefined) {
        wx.setNavigationBarTitle({
          title: '编辑盘源',
          success: function (res) { },
          fail: function (res) { },
          complete: function (res) { },
        })
        myRequest.myRequest('DisSource/workshop/'+id,{},'GET').then(success=>{
          console.log(success)
          let only=[]
          let only1=[]
          let onlyArray=[]
          for (var i = 0; i < success.data.city.length;i++){
            console.log(success.data.city)
            only1.push(success.data.city[i].title)
          }
          for (var j = 0; j < success.data.city[success.data.city_index[0]].children.length; j++) {
            only.push(success.data.city[success.data.city_index[0]].children[j].title);
          }
          onlyArray[0] = only1
          onlyArray[1] = only
          this.setData({
            address:success.data.address,
            img: success.data.img,
            owner:success.data.owner,
            owner_tel:success.data.owner_tel,
            title:success.data.title,
            owndesc: success.data.owndesc,
            rent: success.data.rent == 0 ? '面议' : success.data.rent,
            rent_price: success.data.rent == 0 ? '面议' : success.data.rent,
            sure_rent: success.data.rent == 0 ? '面议' : success.data.rent,
            area: success.data.area,
            city_id:success.data.city_id,
            qu_id:success.data.qu_id,
            onlyArray: onlyArray,
            city:success.data.city,
            city_index: success.data.city_index,
            high: success.data.high,//层高
            floor: success.data.floor,//所在楼层
            startTime: success.data.startTime,
            endTime: success.data.endTime,
            industry_id: success.data.industry_id,
            industry_index: success.data.industry_index,
            tags_id: success.data.tags_id,
            tags_index: success.data.tags_index,
            hangye_id: success.data.hangye_id,
            hangye_index: success.data.hangye_index,
            park_id: success.data.is_park,
            park_index: success.data.is_park,
            changfang_type_id: success.data.changfang_type,
            changfang_type_index: success.data.changfang_type,
            chengzhong_id: success.data.chengzhong,
            chengzhong_index: success.data.chengzhong_index,
            zhengjian_id: success.data.zhengjian_id,
            zhengjian_index: success.data.zhengjian_id,
            isEdit:true,
            is_placehold:false,
            workshop_id:id
          })
        })  
      }
    })
   
      app.CheckSession()
      //登录代码
      if(id!=undefined){}else{
        wx.request({
          url: app.globalData.apiurl + 'DisSource/city',
          data: '',
          header: {},
          method: 'GET',
          dataType: 'json',
          responseType: 'text',
          success: res => {

            this.setData({
              city: res.data
            })
            var data = {
              city: res.data,
              city_index: this.data.city_index,
              onlyArray: this.data.onlyArray,
              city_id: this.data.city[0].id,
              qu_id: this.data.city[0].children[0].id
            };
            
            for (var i = 0; i < data.city.length; i++) {
              data.onlyArray[0].push(data.city[i].title);
            }

            for (var j = 0; j < data.city[data.city_index[0]].children.length; j++) {
              data.onlyArray[1].push(data.city[data.city_index[0]].children[j].title);
            }

            console.log('最终city_id', this.data.city[0].id)
            console.log('最终qu_id', this.data.city[0].children[0].id)
            this.setData(data);
          },
          fail: function (res) { },
          complete: function (res) { },
        })
      }
    
      //获取类型
      wx.request({
        url: app.globalData.apiurl +"DisSource/type",
        data: '',
        header: {},
        method: 'GET',
        dataType: 'json',
        responseType: 'text',
        success: res=> {
            console.log(res)
            this.setData({
              chengzhong:res.data.data.chengzhong,
              hangye:res.data.data.hangye,
              industry:res.data.data.industry,
              zhengjian:res.data.data.zhengjian,
              changfang_type:res.data.data.changfangType,
              park: res.data.data.park,
              tags:res.data.data.tags
            })
            
        },
        fail: function(res) {},
        complete: function(res) {},
      })
      //获取七牛云上传token
      wx.request({
        url: app.globalData.apiurl + "DisSource/uploadToken",
        data: '',
        header: {},
        method: 'GET',
        dataType: 'json',
        responseType: 'text',
        success: res=> {
          if(res.data.code=='success'){
              this.setData({
                  token:res.data.data
              })
          }
        },
        fail: function(res) {},
        complete: function(res) {},
      })
    this.initValidate()
    console.log(this.WxValidate)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  onEditorReady() {
    const that = this
    console.log('onEditorReady')
    wx.createSelectorQuery().select('#editor').context(res=> {
      that.editorCtx = res.context
      if(this.data.id){
        myRequest.myRequest('DisSource/workshop/' + this.data.id, {}, 'GET').then(success => {
          that.editorCtx.setContents({
            html: success.data.owndesc,
            success: (res) => {
              console.log(res)
            },
            fail: (res) => {
              console.log(res)
            }
          })
        })
      }
    
   
    }).exec()
    
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  //
  textareaAInput:function(e){
      console.log(e)
  },
  ChooseImage() {
    console.log(222)
    wx.chooseImage({
      count: 18, //默认9
      sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album'], //从相册选择
      success: (res) => {
          console.log(res)
          this.uploadQiniu(res.tempFilePaths)
       
       
      }
    });
  },
  ViewImage(e) {
    wx.previewImage({
      urls: this.data.img,
      current: e.currentTarget.dataset.url
    });
  },
  DisplayImg(e){
     wx.showModal({
      title: '隐藏图片',
      content: '确定要隐藏图片么',
      cancelText: '取消',
      confirmText: '确定',
      success: res => {
        if (res.confirm) {
          this.setData({
            [`img[${e.currentTarget.dataset.index}].isDisplay`]:0
   
          })
        }
      }
    })
  },
  ShowImg(e){
    wx.showModal({
      title: '显示图片',
      content: '确定要显示图片么',
      cancelText: '取消',
      confirmText: '确定',
      success: res => {
        if (res.confirm) {
          this.setData({
            [`img[${e.currentTarget.dataset.index}].isDisplay`]: 1

          })
        }
      }
    })
  },
  DelImg(e) {
    wx.showModal({
      title: '删除图片',
      content: '确定要删除图片么',
      cancelText: '取消',
      confirmText: '确定',
      success: res => {
        if (res.confirm) {
          this.data.img.splice(e.currentTarget.dataset.index, 1);
          this.setData({
            img: this.data.img
          })
        }
      }
    })
  },

  //数字键盘
  keyTap(e) {
    let keys = e.currentTarget.dataset.keys,
    
      content = this.data.rent,
     
      len = content.length;
      if(content=='面议'){
        content=''
      }
    switch (keys) {
      case '·':
        
        if (len < 11 && content.indexOf('.') == -1) {//如果字符串里有小数点了，则不能继续输入小数点，且控制最多可输入10个字符串
          if (content.length < 1) {//如果小数点是第一个输入，那么在字符串前面补上一个0，让其变成0.
            content = '0.';
          } else {//如果不是第一个输入小数点，那么直接在字符串里加上小数点
            content += '.';
          }
        }
        break;
      case '<':
        content = content.substr(0, content.length - 1);
        break;
      case '面议':
        content ='面议'
        break;  
      default:
        let Index = content.indexOf('.');//小数点在字符串中的位置
        if (Index == -1 || len - Index != 3) {//这里控制小数点只保留两位
          if (len < 11) {//控制最多可输入10个字符串
            content += keys;
          }
        }
        break
    }
    this.setData({ rent:content });
  },
  sureRent(e){
    this.setData({ sure_rent: this.data.rent });
   
      this.setData({
        bottomModal: null
      })
  },
  showRent(e){
    this.setData({
      bottomModal: '1'
    })
  },
  basicSubmit(e){
    const params = e.detail.value

  //  console.log(params)

    // 传入表单数据，调用验证方法
    if (!this.BasicValidate.checkForm(params)) {
      const error = this.BasicValidate.errorList[0]
      wx.showToast({
        title: error.msg,
        icon: 'none',
        image: '',
        mask: true,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
      return false
    }
    console.log(e)
    this.setData({
      floor:e.detail.value.floor,
      high: e.detail.value.high,
      owner: e.detail.value.owner,
      owner_tel: e.detail.value.owner_tel,
      area: e.detail.value.area,
      address:e.detail.value.address
    })
  
    this.setData({
      jibenModal: null
    })
  },
  showBasic(e){
    this.setData({
      jibenModal: '1'
    })
  },
  basicCancel(e){
      this.setData({
        jibenModal:null
      })
  },
  //更多信息弹窗
  showMore(e){
    this.setData({
      moreModal:'1'
    })
  },
  //隐藏信息弹窗
  moreCancel(e){
    this.setData({
      moreModal: null
    })
  },
  //选择类型
  selectIndustry(e){
    let industry_index = this.data.industry_index
    if (industry_index[e.currentTarget.dataset.index] || industry_index[e.currentTarget.dataset.index] == true) {
     industry_index[e.currentTarget.dataset.index] = false
      this.setData({
        industry_index: industry_index
      })
    } else {
      industry_index[e.currentTarget.dataset.index] = true
      this.setData({
        industry_index: industry_index
      })
    }

  },
  //选择承重
  selectChengzhong(e){
      this.setData({
        chengzhong_index: e.currentTarget.dataset.index
      })
  },
  //是否园区
  selectPark(e) {
    let park_index = this.data.park_index
    if (park_index === e.currentTarget.dataset.index) {
      park_index = ''
    } else {
      park_index = e.currentTarget.dataset.index
    }
    this.setData({
      park_index: e.currentTarget.dataset.index
    })
  },
  //厂房证件
  selectZhengjian(e){
    let zhengjian_index=this.data.zhengjian_index
    if(zhengjian_index===e.currentTarget.dataset.index){
      zhengjian_index=''
    }else{
      zhengjian_index= e.currentTarget.dataset.index
    }
    this.setData({
     zhengjian_index
    })
  },
  //行业
  selectHangye(e) {
    let hangye_index=this.data.hangye_index
    
    if (hangye_index[e.currentTarget.dataset.index] || hangye_index[e.currentTarget.dataset.index]==true){
      hangye_index[e.currentTarget.dataset.index]=false
      this.setData({
        hangye_index:hangye_index
      })
    }else{
      hangye_index[e.currentTarget.dataset.index] = true
      this.setData({
        hangye_index: hangye_index
      })
    }
   
  },
  //标签
  selectTags(e) {
    let tags_index = this.data.tags_index
    if (tags_index[e.currentTarget.dataset.index] || tags_index[e.currentTarget.dataset.index] == true) {
      tags_index[e.currentTarget.dataset.index] = false
      this.setData({
        tags_index: tags_index
      })
    } else {
      tags_index[e.currentTarget.dataset.index] = true
      this.setData({
        tags_index: tags_index
      })
    }

  },
  //专业厂房
  selectChangfangType(e) {
    let changfang_type_index = this.data.changfang_type_index
    if (changfang_type_index === e.currentTarget.dataset.index) {
      changfang_type_index = ''
    } else {
      changfang_type_index = e.currentTarget.dataset.index
    }
    this.setData({
      changfang_type_index
    })
  },
  //确定更多信息
  sureMore(e){
    console.log(this.data.hangye_index)
    let industry_id=[]
    let hangye_id=[]
    let chengzhong_id=''
    let zhengjian_id=''
    let tags_id=[]
    let changfang_type_id=''
    let park_id=''
    console.log(this.data.industry_index)
    if (this.data.industry_index.length > 0){

   //   industry_id = this.data.industry[this.data.industry_index].id
      for (let i = 0; i <= this.data.industry_index.length; i++) {
        console.log(this.data.industry_index)
        if (this.data.industry_index[i] != undefined) {
          console.log(222)
          if (this.data.industry_index[i] == true) {
            console.log(industry_id)
            industry_id.push(this.data.industry[i].id)
          }
        }
      }
      console.log(industry_id)
      industry_id = industry_id.toString()
    }


    if (this.data.hangye_index.length>0) {
      for (let i = 0; i<=this.data.hangye_index.length;i++){
        if (this.data.hangye_index[i]!=undefined){
          if (this.data.hangye_index[i] == true){
            hangye_id.push(this.data.hangye[i].id)
          }
        }
      
      }
      hangye_id = hangye_id.toString()
    }
    if (this.data.tags_index.length > 0) {
      for (let i = 0; i <= this.data.tags_index.length; i++) {
        if (this.data.tags_index[i] != undefined) {
          if (this.data.tags_index[i] == true) {
            tags_id.push(this.data.tags[i].id)
          }
        }
      }
      tags_id = tags_id.toString()
    }
    if (this.data.chengzhong_index !== undefined && this.data.chengzhong_index!=='' ) {
      chengzhong_id = this.data.chengzhong[this.data.chengzhong_index].id
    }
    if (this.data.zhengjian_index !== undefined) {
      zhengjian_id = this.data.zhengjian_index
    }
    if (this.data.changfang_type_index !== undefined ) {
      changfang_type_id = this.data.changfang_type_index
    }
    if (this.data.park_index !== undefined) {
      park_id = this.data.park_index
    }
   this.setData({
     industry_id,
     hangye_id,
     tags_id,
     chengzhong_id,
     zhengjian_id,
     changfang_type_id,
     park_id,
    moreModal:null
   })
   /* industry_id: '',
    hangye_id: '',
    chengzhong_id: '',
    zhengjian_id: '',
    changfang_type_id: '',
    park_id: '',*/
  },
  uploadQiniu(tempFilePaths) {
    console.log(tempFilePaths)

    let token = this.data.token;
    var that = this;
    for(var i=0;i<tempFilePaths.length;i++){
    wx.uploadFile({
      url: 'https://upload-z2.qiniup.com',
      name: 'file',
      filePath: tempFilePaths[i],
      header: {
        "Content-Type": "multipart/form-data"
      },
      formData: {
        token: token,
      },
      success: res=> {
        let data = JSON.parse(res.data)
        console.log('qiniu');
        console.log(res);
       
       let img = this.data.img
        img.push({img: app.globalData.qiniu_url + '' + data.key, isDisplay:1})
        console.log(img)
        this.setData({
          img:img
        })             
        
      },
      fail: function (res) {
        console.log(res)
      }
    });
    }
  },
  picker(e){
    this.setData({
      isPickerShow: true,
      isPickerRender: true,
      chartHide: true
    });
  },
  pickerShow: function () {
    this.setData({
      isPickerShow: true,
      isPickerRender: true,
      chartHide: true
    });
  },
  pickerHide: function () {
    this.setData({
      isPickerShow: false,
      chartHide: false
    });
  },

  bindPickerChange: function (e) {
    console.log("picker发送选择改变，携带值为", e.detail.value);
    console.log(this.data.sensorList);

    this.getData(this.data.sensorList[e.detail.value].id);
    // let startDate = util.formatTime(new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 7));
    // let endDate = util.formatTime(new Date());
    this.setData({
      index: e.detail.value,
      sensorId: this.data.sensorList[e.detail.value].id
      // startDate,
      // endDate
    });
  },
  setPickerTime: function (val) {
    console.log('setPickerTime',val);
    let data = val.detail;
    let startTime = val.detail.startTime.split(' ')[0]
    let endTime = val.detail.endTime.split(' ')[0]
    console.log(util.dateFormat("YYYY-mm-dd", new Date(data.startTime)))
    this.setData({
      startTime,
      endTime
    });
  },

  initValidate() {
    let basicRule={
      owner: {
        required: true
      },
      owner_tel: {
        required: true,
        tel: true,
      },
      area: {
        required: true,
        number: true
      },
      
   
    }
    let rules = {
      title: {
          required:true
      },
      owndesc:{
        required:true
      },
     
      slider:{
        required:true,
        minlength:15,
      },
      rent: {
        required:true
      },
      owner:{
        required: true
      },
      area: {
        required: true,
        number:true
      },
      start_day:{
        required: true
      },
      end_day: {
        required: true
      },
      industry:{
        required:true
      },
      zhengjian_id:{
        required: true
      },
      owner_tel:{
        required:true,
        tel: true,
      },
     
      
      hangye:{
        required:true,
      }     
      
    }
    let message = {
     
      title: {
        required: '请输入厂房标题'
      },
      owndesc: {
        required: '请输入厂房内容'
      },
      slider: {
        required: '请上传图片',
        minlength:'图片最少上传15张'
      },
      rent: {
        required: '请输入租金',
      },
      owner: {
        required: '请输入业主姓名'
      },
      area: {
        required: '请填写面积',
        number:'面积只能是数字'
      },
      start_day: {
        required: '请选择开始时间'
      },
      end_day: {
        required: '请选择结束时间'
      },
      industry: {
        required: '请选择类型'
      },
      zhengjian_id: {
        required: '请选择证件'
      },
      owner_tel: {
        required: '请输入联系方式',
        tel: '请输入正确的手机格式',
      },
      hangye: {
        required: '请选择行业',
      }     
    }
    console.log('valieda')
    //实例化当前的验证规则和提示消息
   // this.WxValidate = new WXalidate(rules, message);
    this.WxValidate = new WxValidate(rules, message)
    this.BasicValidate = new WxValidate(basicRule, message)
  },
  //发布取消
  CancelPublished(e){
    wx.showModal({
      title: '确定要取消发布么',
      content: '已填写的内容将会被清除',
      showCancel: true,
      cancelText: '否',
      cancelColor: '',
      confirmText: '是',
      confirmColor: '#c30905',
      success: function(res) {
        wx.redirectTo({
          url: '/pages/index/index',
          success: function(res) {},
          fail: function(res) {},
          complete: function(res) {},
        })
      },
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  //得到标题值
  GetTitle(e){
      console.log(e)
      this.setData({
        title:e.detail.value
      })
  },
  //得到内容
  GetDesc(e){
    console.log(e)
    let is_placehold=this.data.is_placehold
    if(e.detail.text==' '||e.detail.text=='\n'){
     
        is_placehold=true
     
    }else{
        is_placehold=false
    }
    this.setData({
      owndesc:e.detail.html,
      is_placehold:is_placehold
    })
  },
  //发布
  SurePublished(e){
      if(this.data.fabu==1){
          return
      }
      this.setData({
        fabu:1
      })
    let param = {
      slider: this.data.img,
      title: this.data.title,
      rent: this.data.sure_rent,
      owner: this.data.owner,
      owner_tel: this.data.owner_tel,
      area: this.data.area,
      high: this.data.high,
      floor: this.data.floor,
      start_day: this.data.startTime,
      end_day: this.data.endTime,
      is_park: this.data.park_id,
      hangye: this.data.hangye_id,
      tags_id:this.data.tags_id,
      city_id:this.data.city_id,
      qu_id:this.data.qu_id,
      address: this.data.address,
      changfang_type: this.data.changfang_type_id,
      changfang_type_index: this.data.changfang_type_id,
      chengzhong_id: this.data.chengzhong_id,
      zhengjian_id: this.data.zhengjian_id,
      industry: this.data.industry_id,
      owndesc: this.data.owndesc,
      code:this.data.code,
      edit:this.data.edit,
    }
    if (!this.WxValidate.checkForm(param)) {
      const error = this.WxValidate.errorList[0]
      console.log(error)
     this.setData({
        fabu: null
      })
      wx.showToast({
        title: error.msg,
        icon:'none',
        success: function (res) { console.log(e) },
        fail: function (res) { },
        complete: function (res) { },
      })
      return false
    }
      if(this.data.isEdit==true){
        myRequest.myRequest('DiskSource/edit/'+this.data.workshop_id,param,'POST').then(res=>{
          console.log(res)
          if(res.code=='success'){
            if(this.data.edit==1){
            
              wx.showToast({
                title: res.message,
                duration: 4000,
                success: res =>{
                  setTimeout(function () {
                    wx.navigateBack({
                      delta: 1,
                    })
                  },3000)
               
                },
                fail: function(res) {},
                complete: function(res) {},
              })
              return
            }
            wx.redirectTo({
              url: '/pages/mine-shenqing/mine-shenqing',
              success: function(res) {},
              fail: function(res) {},
              complete: function(res) {},
            })
          }else{
            wx.showToast({
              title: res.message,
              icon: 'none',
            })
            this.setData({
              fabu: null,
            })
          }
        })
      }else{
      myRequest.myRequest(
          'DiskSource/created',
          param,
          'post'
      ).then(res=>{
        console.log(res)
        if(res.code==="success"){
            this.setData({
              fabu:null,
              successModal:'1'
            })
        }else{
          wx.showToast({
            title: res.message,
            icon: '',
            image: '',
            duration: 0,
            mask: true,
            success: function(res) {},
            fail: function(res) {},
            complete: function(res) {},
          })
        }
        this.setData({
          fabu: null,
        })
      })
      }
  },
  Know(e){
    this.setData({
      successModal:null
    })
    wx.redirectTo({
      url: '/pages/index/index',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  indCityPickerChange: function (e) {
    var city = this.data.city,
      city_index = this.data.city_index,
      onlyArray = this.data.onlyArray;

    console.log('picker发送选择改变，携带值为', e.detail.value);
    //此处e.detail.value为当前选择的列的下标值数组，如[0,1,0]

    console.log('picker最终选择值为：', onlyArray[0][city_index[0]], onlyArray[1][city_index[1]]);
    console.log('最终city_id', city[city_index[0]].id)
    console.log('最终qu_id', city[city_index[0]].children[city_index[1]].id)
    this.setData({
      city_index: e.detail.value,
      city_id: city[city_index[0]].id,
      qu_id: city[city_index[0]].children[city_index[1]].id
    })
  },

  //多列自创选择器换列方法
  bindCityPickerColumnChange: function (e) {
    console.log(e)
    var city = this.data.city,
      city_index = this.data.city_index,
      onlyArray =this.data.onlyArray

    city_index[e.detail.column] = e.detail.value;
     console.log(onlyArray);
    city[e.detail.column]
    switch (e.detail.column) {
      case 0:
        let only=[] 
        for (var j = 0; j < city[e.detail.value].children.length; j++) {
          only.push(city[e.detail.value].children[j].title);
        }
        onlyArray[1]=only
        break;
    }
 
    this.setData({
      onlyArray: onlyArray,
      city_index: city_index
    });
  
  }
})